//implement GTimer
//andycai_sc 2011-05-27

#include "GParallel/GTimerImpl.h"

GTimer::GTimer()
{
	m_timerImpl = GTimerImplCreator::create(this);
}

GTimer::~GTimer()
{
	if (m_timerImpl != 0)
		delete m_timerImpl;
}

void GTimer::begin(long mills)
{
	m_timerImpl->beginImpl(mills);
}

void GTimer::cancel()
{
	m_timerImpl->cancelImpl();
}

GTimerImpl* GTimerImplCreator::create(GTimer* timer)
{
#if (defined(USE_ACE_ALL) && !defined(NO_ACE_TIMER)) || defined(USE_ACE_TIMER)
	return createTimerFromAce(timer);
#elif (defined(USE_POCO_ALL) && !defined(NO_POCO_TIMER)) || defined(USE_POCO_TIMER)
	return createTimerFromPoco(timer);
#elif (defined(USE_QT_ALL) && !defined(NO_QT_TIMER)) || defined(USE_QT_TIMER)
    return createTimerFromQt(timer);
#else
    return createTimerFromGToy(timer);
#endif
}
